# build project
kind: pipeline
type: docker
name: build_production

trigger:
  event:
    include:
      - push
  branch:
    include:
      - main

#trigger:
#  event:
#    -push
#  branch:
#    -main

steps:
  - name: notify_about_start
    image: appleboy/drone-discord
    settings:
      webhook_id:
        from_secret: DISCORD_WEBHOOK_ID
      webhook_token:
        from_secret: DISCORD_WEBHOOK_TOKEN
      username: billiard_bot
      message: >
        ⚙️ Production [deploy](<{{ build.link }}>) of `build ${DRONE_BUILD_PARENT}` of `{{repo.name}}`:`{{commit.branch}}`.
  - name: build_production
    image: appleboy/drone-ssh
    volumes:
      - name: docker_sock
        path: /var/run/docker.sock
    settings:
      host:
        from_secret: HOST_DOMAIN
      username:
        from_secret: HOST_USERNAME
      password:
        from_secret: HOST_PASSWORD
      port: 22
      script:
        - cd services/billiard
        - make stop-production
        - git pull
        - make build-production
        - make start-production
